package second.binarytree.solution05;

public class Solution05_111 {
    public int minDepth(TreeNode root) {
        if (root == null) return 0;

        int left = minDepth(root.left);
        int right = minDepth(root.right);

        if (left != 0 && right != 0) return Math.min(left, right) + 1;
        return left == 0 ? right + 1 : left + 1;
    }
}
